/** @type {import('next').NextConfig} */
const path = require('path')
const isProd = process.env.NODE_ENV === 'production';
const nextConfig = {
  // assetPrefix: isDev ? undefined : 'https://static.shutu.cn',
  // distDir: isProd ? '_next_build' : '_next',
  assetPrefix: isProd ? "//js.tuguaishou.com/ips_ai_home/mobile" : "",
  async rewrites() {
    return [
      {
        source: '/',
        destination: '/headshot',
      },
      {
        source: '/apiv5',
        destination: 'https://818ps.com/apiv5/:path*',
      },
      {
        source: '/se',
        destination: 'https://gapi.818ps.com/se/:path*',
      },
      {
        source: '/v4/:path*',
        destination: 'https://api.818ps.com/v4/:path*',
      },
      {
        source: '/:path*',
        destination: 'https://818ps.com/:path*',
      },
    ];
  },
  sassOptions: {
    includePaths: [path.join(__dirname, 'styles')],
  },
  images: {
    domains: [],
    unoptimized: true //nextjs 12.3.0 之后生效
  },
  publicRuntimeConfig: {
    env: {
      NODE_ENV: process.env.NODE_ENV
    }
  },
  serverRuntimeConfig: {
    env: {
      NODE_ENV: process.env.NODE_ENV
    }
  },
  sassOptions: {
    includePaths: [path.join(__dirname, 'styles')],
  },
  typescript: {
    ignoreBuildErrors: true,
  },
  // next 兼容 ant-mobile
  transpilePackages: ['antd-mobile'],
}

module.exports = nextConfig
